package com.itheima.mapper;

import com.itheima.domain.Student;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface StudentMapper {
    @Select("select * from student ")
    @Results({
            @Result(column = "id",property = "id",id = true),
            @Result(column = "name",property = "name"),
            @Result(column = "age",property = "age"),

            @Result(
                    property = "classes",
                    javaType = ClassesMapper.class,
                    column = "cid",
                    one = @One(select = "com.itheima.mapper.ClassesMapper.findByCid",fetchType = FetchType.LAZY)
            )
    })
    List<Student> findAll();
}
